# -*- coding: utf-8 -*-
"""
webfolio.views
"""


from kay.utils import render_to_response

from kay.i18n import gettext as _
from kay.auth.decorators import login_required, admin_required
from kay.utils import create_logout_url

from google.appengine.ext import db

from werkzeug import (
  unescape, redirect, Response,append_slash_redirect,
)

from webfolio.models import Card

# Create your views here.

@login_required
def index(request):
    return render_to_response('webfolio/index.html', {'message': 'Hello'})


def photoImage(request):
    """"""
    key = request.values.get('key','')
    image_type = request.values.get('type','')
    if not key:
        return Response(u'img',mimetype='image/jpeg')
    card = db.get(key)
    if image_type == "thumb" and card.thumbnail:
        return Response(card.thumbnail, mimetype='image/jpeg')
    elif card.photo:
        return Response(card.photo, mimetype='image/jpeg')
    else:
        return Response(u'img',mimetype='image/jpeg')
